package com.example.ymm.modules1.service.impl.user;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.ymm.base.BaseServiceImpl;
import com.example.ymm.model.TableList;
import com.example.ymm.model.YmPageDto;
import com.example.ymm.modules1.entity.my.user.DbShopCard;
import com.example.ymm.modules1.mapper.my.user.DbShopCardMapper;
import com.example.ymm.modules1.query.DbShopCardQueryCriteria;
import com.example.ymm.modules1.service.user.DbShopCardService;
import com.example.ymm.util.QueryHelpPlus;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Slf4j
public class DbShopCardServiceImpl extends BaseServiceImpl<DbShopCardMapper, DbShopCard> implements DbShopCardService {

    @Override
    public TableList<DbShopCard> list(DbShopCardQueryCriteria criteria, YmPageDto pageDto) {
        IPage<DbShopCard> page = new Page<DbShopCard>(pageDto.getPage(),pageDto.getPageSize());
        QueryWrapper predicate = QueryHelpPlus.getPredicate(DbShopCard.class, criteria);
//        predicate.orderByDesc("create_time");
        baseMapper.selectPage(page, predicate);
        TableList<DbShopCard> tableList=new TableList(page);
        return tableList;
    }

    public List<DbShopCard> queryAll(DbShopCardQueryCriteria criteria) {
        List<DbShopCard> result =baseMapper.selectList(QueryHelpPlus.getPredicate(DbShopCard.class, criteria));
        return result;
    }
}
